# coding:utf-8
# *******************************************************************
# * Copyright 2021-2080 evilbinary
# * 作者: evilbinary on 01/01/20
# * 邮箱: rootdebug@163.com
# ********************************************************************
import os
nasm_env = Environment(tools = ['nasm'],
                  ENV=os.environ,
                  AS='nasm',
                  ASFLAGS='',
                  OBJSUFFIX=''
                  )

# print dir(env)
nasm_env.StaticObject('boot', ['boot.s'],ASFLAGS='-f bin')
# nasm_env.StaticObject('init.o', 'init.s',ASFLAGS="-f elf32")



Import('env')               

env.GenerateKernelSize('config.h',['../../duck/init/kernel.elf'])


include=[
    '.',
    'include',
    '../../duck',
    '../../duck/platform/'+env['PLATFORM']
]

source=['init.c','config.h']

env.Program('init.elf', 
    source,
    CPPPATH=include,
    CFLAGS='$CFLAGS -fno-stack-protector  -I. -Iinclude  -Iarch -std=c99 -std=gnu99 -w  ',
    LINKFLAGS= '$LINKFLAGS  -T boot/x86/link.ld ') #-Ttext 0x0500 -Wl,-section-start=.apu_boot=0x1000

env.Objcopy('init.bin','init.elf',OBJCOPYFLAGS='-j .text -O binary -S')